<template>
  <div class="vehicleAppListWrap h100">
    <s-table
      ref="table"
      class="h100"
      :columns="columns"
      :data="loadData"
      row-key="id"
    >
      <template slot="softwareName" slot-scope="text">
        <table-ellipsis :text="text" ></table-ellipsis>
      </template>
      <template slot="partNumber" slot-scope="text">
        <table-ellipsis :text="text" ></table-ellipsis>
      </template>
      <template slot="partName" slot-scope="text">
        <table-ellipsis :text="text" ></table-ellipsis>
      </template>
      <template slot="partSN" slot-scope="text">
        <table-ellipsis :text="text" ></table-ellipsis>
      </template>
      <template slot="currentVersion" slot-scope="text">
        <table-ellipsis :text="text" ></table-ellipsis>
      </template>
      <template slot="operation" slot-scope="text,record">
        <a @click.stop="handleUpdateEvt(record.appCode)">{{ $t('upgradeInformation') }}</a>
      </template>
    </s-table>
  </div>
</template>
<script>
import { STable } from '@/components'
import { vehicleTbColumns } from '../config/list'
import TableEllipsis from '@/components/Ellipsis/TableEllipsis'
import vehicleApi from '@/api/modules/system/vehicleMana'
export default {
  components: {
    STable,
    TableEllipsis
  },
  props: {
    defaultQuery: {
      type: Object,
      default () {
        return {}
      }
    },
    time: {
      type: Number,
      default: 156423
    }
  },
  data () {
    return {
      columns: vehicleTbColumns
    }
  },
  watch: {
    time: {
      handler () {
        this.$nextTick(() => {
          this.refreshData()
        })
      }
    }
  },
  methods: {
    handleUpdateEvt (softwareDid) {
      this.$emit('updateinfoevt', softwareDid)
    },
    loadData (parameter) {
      const params = { ...parameter, ...this.defaultQuery }
      return vehicleApi.getVehicleAppList(params)
    },
    refreshData (isToFirstPage = true) {
      let obj = null
      if (isToFirstPage) {
        obj = { current: 1 }
      }
      this.$refs.table.loadData(obj)
    }
  }
}
</script>
<style lang="less" scoped>
</style>
